const db = require('../../models/index');
const DAO = require('../../dao/sql-option-dao');
const Favorite = db.favorite;

// 创建收藏
exports.create = (req, res) => {
    const createInfo = req.body;
    DAO.create(Favorite, createInfo, data => {
        res.sendResult(data);
    })
};

// 查询所有收藏夹
exports.findAll = (req, res) => {
    const fAllInfo = req.body;
    DAO.list(Favorite, fAllInfo, list => {
        res.sendResult(list);
    });
};

// 根据id查询
exports.findOne = (req, res) => {
    const fOneInfo = req.body;
    DAO.findOne(Favorite, fOneInfo, data => {
        res.sendResult(data);
    });
};

// 更新
exports.update = (req, res) => {
    const updateInfo = req.body;
    DAO.update(Favorite, updateInfo, {id:updateInfo.id}, data => {
        res.sendResult(data);
    });
};

// 删除
exports.delete = (req, res) => {
    const deleteInfo = req.body;
    DAO.delete(Favorite, {id:deleteInfo.id}, data => {
        res.sendResult(data);
    });
};

// 删除所有
exports.deleteAll = (req, res) => {
    DAO.deleteAll(Favorite, data => {
        res.sendResult(data);
    });
};
